<%@page import="com.zimper.model.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Jsp_JavaBean登录Demo</title>
	</head>
	<body>
		<%-- 创建javabean --%>
		<jsp:useBean id="user" class="com.zimper.model.User" />
		<%-- 收集参数 封装参数（比直接使用jsp，在这块是简单的） --%>
		<jsp:setProperty name="user" property="*" />
		<%
		String submitFlag = request.getParameter("submitFlag");
		if ("checkLogin".equals(submitFlag)) {
			if ("yaoper".equals(user.getUsername()) && "12345".equals(user.getPassword())) {
				out.write("<h1 style='color:red'>login success!</h1>");
			} else {
				out.write("<h1>login fail!~~~~(>_<)~~~~</h1>");
			}
		} else {
		%>
		<form action="" method="post">
			<input type="hidden" name="submitFlag" value="checkLogin"/>
			username:<input type="text" name="username"/><br/>
			password:<input type="password" name="password"/><br/>
			<input type="submit" value="login"/>
		</form>
		<%
			}
		%>
	</body>
</html>